package com.aizuda.boot.modules.business.dict.controller;

import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.business.dict.entity.vo.CountryDictRespDTO;
import com.aizuda.boot.modules.business.dict.service.CountryDictService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 国家字典控制器
 */
@Slf4j
@Tag(name = "国家字典管理")
@RestController
@RequestMapping("/dict/country")
public class CountryDictController {
    
    @Resource
    private CountryDictService countryDictService;
    
    @Operation(summary = "获取所有国家列表")
    @GetMapping("/list")
    public SingleResponse<List<CountryDictRespDTO>> getAllCountries() {
        try {
            log.info("查询所有国家字典数据");
            List<CountryDictRespDTO> countries = countryDictService.getAllCountries();
            return SingleResponse.of(countries);
        } catch (Exception e) {
            log.error("查询国家字典数据失败", e);
            return SingleResponse.failure(500500, "查询国家字典数据失败: " + e.getMessage());
        }
    }
} 